/*
 * @lc app=leetcode.cn id=367 lang=golang
 *
 * [367] 有效的完全平方数
 */

// 1. 二分查找
// @lc code=start
func isPerfectSquare(num int) bool {
	l, r := 0, num
	temp := -1
	for l <= r {
		mid := l + (r-l)/2
		if mid*mid > num {
			r = mid - 1
		} else {
			l = mid + 1
			temp = mid
		}
	}
	return temp*temp == num
}

// @lc code=end

